<?
	include('chksession.php');
	session_start();
    $data = file_get_contents("php://input");
    $objData = json_decode($data);
	
	   $msg='';
       $Can_Date= $objData->Can_Date;
	   $Pax_Name= $objData->Pax_Name;
	   $No_of_Pax= $objData->No_of_Pax;
	   $Airline= $objData->Airline;
	   $Sector= $objData->Sector;
	   $Net_Rate= $objData->Net_Rate;
	   $Refund_Amt= $objData->Refund_Amt;
	   $Refund_Date= $objData->Refund_Date;
	   $Agent_Rate= $objData->Agent_Rate;
	   $Agent_Ref_Amt = $objDate->Agent_Ref_Amt;
	   $Reference_Date = $objDate->Reference_Date;
	   $Comment = $objDate->Comment;
	   $enteredby = $objDate->enteredby;
	   $entrydt = $objDate->entrydt;
	   $status = $objDate->status;
	      
	   
		echo $Can_Date.",".$Pax_Name.",".$No_of_Pax.",".$Airline.",".$Sector.",".$Net_Rate.",".$Refund_Date.",".$Agent_Rate.","$Agent_Ref_Amt.","$Reference_Date.",".$Comment.",".$enteredby.",".entrydt$;
	   
		$enteredby=$_SESSION['username'];
		include('conn.php');
		$sqlc="select count(*) cnt from canceltrandetails where status = 0 ;
		$resc=mysql_query($sqlc);
		$rowc=mysql_fetch_assoc($resc);
		if (strlen($name)>1)
		{
			if($rowc['cnt']==0)
			{
				$sql="insert into canceltrandetails(Can_Date,Pax_Name,No_of_Pax,Airline,Sector,Net_Rate,Refund_Amt,Refund_Date,Agent_Rate,Agent_Ref_Amt,Reference_Date, Comment,enteredby,entrydt)
				values('".$Can_Date."','".$Pax_Name."','".$No_of_Pax."','".$Airline."','".$Sector."','".$Net_Rate."','".$Refund_Amt."','".$Refund_Date."','".$Agent_Ref_Amt."','".$Reference_Date."','".$Comment."','".$enteredby."',sysdate())";
				$res=mysql_query($sql);
				if($res)
					$msg='Record saved successfully';	
					
			}
			else
			{
				$sql="update canceltrandetails set email='".$email."',entrydt=sysdate(),status=123 where custid=".$custid;
				$res=mysql_query($sql);
				if($res)
					$msg='Record updated successfully...';					
			}
		}
		else
		{
			$msg='Blank Name not Allowed';
		}			
	    echo $msg;
?>